package com.student.db;


import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;

import java.util.List;

import io.reactivex.rxjava3.core.Completable;
import io.reactivex.rxjava3.core.Flowable;
import io.reactivex.rxjava3.core.Single;

@Dao
public interface AccountDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    public Completable insert(AccountEntity student);

    @Query("SELECT * FROM db_account  WHERE  (userName=:userName)")
    public Single<AccountEntity> searchAccountByName(String userName);


    @Query("SELECT * FROM db_account Where (floorNo=:floorNo) ")
    public Flowable<List<AccountEntity>> getAccounts(String floorNo);

    @Query("SELECT * FROM db_account WHERE ((:content='' or name  like  '%' || :content || '%') or (:content='' or roomNo  like  '%' || :content || '%')) AND  (floorNo=:floorNo)")
    public Flowable<List<AccountEntity>> searchAccount(String content,String floorNo);

    @Delete
    public Completable deleteAccount(AccountEntity accountEntity);
}
